<template>
  <div class="rebate_tab">
    <ul>
      <li 
        v-for="(item, index) in list" 
        :key="index"
        @click="itemClick(index)"
        :class="[currentIndex === index? 'list_active': '']">
        {{ item }}
      </li>
      <div
        class="line"
        :style="'transform: translateX(' + this.isActive + 'rem)'"
      ></div>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    currentIndex: {
      type: Number,
      default: 0,
    },
    list: {
      type: Array,
      default: null,
    },
  },
  methods: {
    itemClick(index) {
      this.$emit('item-click', index)
    }
  },
  computed: {
    isActive() {
      return this.currentIndex * 5 + 2.28 
    }
  },
};
</script>

<style lang="less" scoped>
.rebate_tab {
  box-sizing: border-box;
  border-top: 0.013333rem solid #b2b2b2;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 1.173333rem;
  width: 10rem;
  height: 1.093333rem;
  background: #fff;
  font-size: .346667rem;
  color: #666666;
  text-align: center;
  line-height: 1.093333rem;
  ul {
    position: relative;
    display: flex;
    li {
      flex: 1;
    }
    .list_active {
      color: #222;
      font-weight: bold;
      font-size: .4rem;
    }
    .line {
      width: .44rem;
      height: .053333rem;
      background: #FF5543;
      position: absolute;
      bottom: 0;
      left: 0;
      transition: 0.3s ease;
    }
  }
}
</style>